//
//  ZQBaseTabbarVc.swift
//  Sina Blog
//
//  Created by 张强 on 16/5/10.
//  Copyright © 2016年 张强. All rights reserved.
//

import UIKit

class ZQBaseTabbarVc: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
    
        
        let tabbar = ZQTabbar()
        setValue(tabbar, forKey: "tabBar")
        tabbar.ComposeClosure = {
        print("compose")
        
        }
        
        
        
        addChildViewController(ZQHomeTableViewController(), title: "主页", imgName: "tabbar_home")
        addChildViewController(ZQMessageTableViewController(), title: "消息", imgName: "tabbar_message_center")
        addChildViewController(ZQDiscoverTableViewController(), title: "发现", imgName: "tabbar_discover")
        addChildViewController(ZQProfileTableViewController(), title: "我的", imgName: "tabbar_profile")
        
        
        
        
        
        
        
    }

    func addChildViewController(childController: UIViewController, title: String, imgName:String ) {
        childController.title = title
        childController.tabBarItem .setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orangeColor(), NSFontAttributeName:UIFont.systemFontOfSize(14)], forState: UIControlState.Selected)
        childController.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -5, right: 0)
        
        childController.tabBarItem.image = UIImage(named: imgName)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        childController.tabBarItem.selectedImage = UIImage(named: imgName + "_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        
        
        
        
        
        
        let nav = UINavigationController.init(rootViewController: childController)
        addChildViewController(nav)
        
        
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    
}
